#ifndef _BUOLA_WIDGETS_CBUTTON_H_
#define _BUOLA_WIDGETS_CBUTTON_H_

#include <buola/utility/uevent.h>
#include <buola/widgets/cwidget.h>
#include <buola/image/cpicture.h>

namespace buola { namespace gui {

///\addtogroup widgets
///@{

////////////////////////////////////////////////////////////////////////////

/// push button

///
///
///
////////////////////////////////////////////////////////////////////////////

class CButton : public CWidget
{
public:
    CButton();
    ~CButton();

    void SetIconImage(PIcon pIcon);
    void SetIconImage(const std::string &pIconName);
    void SetImage(const img::CPicture &pNormal,const img::CPicture &pHover=img::CPicture(),
                  const img::CPicture &pPressed=img::CPicture());
    void SetPicture(const img::CPicture &pNormal,const img::CPicture &pHover=img::CPicture(),
                  const img::CPicture &pPressed=img::CPicture());
    //! sets the caption to display for the box
    void SetCaption(const std::wstring &pCaption);
    
    //! returns the caption to display for the box
    const std::wstring &Caption()       {   return mCaption;        }
    const img::CPicture &NormalImage()  {   return mNormalImage;    }
    const img::CPicture &HoverImage()   {   return mHoverImage;     }
    const img::CPicture &PressedImage() {   return mPressedImage;   }

    bool Pressed()                      {   return mPressed;        }
    bool PointerInside()                {   return mPointerInside;  }
    
    virtual void GetPropertyNames(std::vector<std::string> &pNames);
    virtual void SetProperty(const std::string &p,const UAny&);

public:
    virtual void OnExpose(const CExposeEvent &pE);
    virtual void OnButtonDown(const CMouseEvent &pE);
    virtual void OnButtonUp(const CMouseEvent &pE);
    virtual void OnMouseIn(const CMouseEvent &pE);
    virtual void OnMouseOut(const CMouseEvent &pE);
    virtual void OnFocusIn(const CFocusEvent &pE);
    virtual void OnFocusOut(const CFocusEvent &pE);
    virtual void OnKeyDown(const CKeyEvent &pE);
    virtual void OnKeyUp(const CKeyEvent &pE);
    virtual void OnStyleChanged(TStyle);

public:
    UEvent<void()> ePressed;

private:
    bool mPressed;
    bool mPointerInside;

    img::CPicture mNormalImage;
    img::CPicture mHoverImage;
    img::CPicture mPressedImage;

    std::wstring mCaption;
};

///@}

/*namespace gui*/ } /*namespace buola*/ }

#endif
